<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
JTable::addIncludePath ( JPATH_COMPONENT. DS . 'tables' );
//kiem tra dang nhap va phan quyen
    $user = JFactory::getUser();
  
    $db=&JFactory::getDBO();
                    $lenh = "SELECT count(*) FROM #__erp_employee_access where id_user='".$user->get('id')."' and id_function = 1";
                    $db->setQuery($lenh);
                    $rs = $db->loadResult();
                    //echo $rs;die;
                    if($rs!=1)
                    {
                        //$_SESSION[user_id] = $data->id;
                          global $mainframe;
                        $mainframe->redirect( "index.php", "Bạn không có chức năng này.",'error');
                        return;      
                    }
                   
$controller = JRequest::getVar('view', 'danh_sach_san_pham' );//trang mac dinh
$path = JPATH_COMPONENT . DS . 'controllers' . DS . $controller . '.php';
$user = & JFactory::getUser();
if (file_exists ( $path )) {
	require_once $path;
} else {	
	require_once JPATH_COMPONENT . DS . 'controllers' . DS . 'controller.php';
}
$classname = 'kinh_doanhController' . ucfirst($controller);//doi ten com
$controller = new $classname (); 
$controller->execute ( JRequest::getVar ( 'task' ) );
$controller->redirect ();